﻿using System;
using System.Text;

namespace DllShepherd.Core.Extension
{
    public static class EnumExtensions
    {
        public static string ToSentence(this Enum input)
        {
            var inputString = input.ToString();

            if (String.IsNullOrEmpty(inputString))
                return inputString;

            var result = new StringBuilder(32);

            result.Append(Char.ToUpper(inputString[0]));
            for (var i = 1; i < inputString.Length; i++)
            {
                if (Char.IsUpper(inputString[i]))
                {
                    result.Append(" ");
                    result.Append(Char.ToLower(inputString[i]));
                }
                else
                {
                    result.Append(inputString[i]);
                }
            }

            return result.ToString();
        }
    }
}
